Skip to content

Upgrade Struct2Tensor to TensorFlow 2.21.0#59

Open
vkarampudi wants to merge 20 commits intogoogle:masterfrom
vkarampudi:testing1
Open

Upgrade Struct2Tensor to TensorFlow 2.21.0#59
vkarampudi wants to merge 20 commits intogoogle:masterfrom
vkarampudi:testing1

Conversation

@vkarampudi
Copy link
Copy Markdown
Collaborator

@vkarampudi vkarampudi commented Apr 10, 2026

This PR upgrades struct2tensor to support TensorFlow 2.21.0 and resolves various build system incompatibilities, dependency conflicts, and compilation errors encountered during the process.

Key Changes

1. TensorFlow 2.21.0 Dependency Resolution Conflicts

  • Updated .bazelversion to 7.7.0 to align with TensorFlow 2.21.0 requirements.
  • Updated WORKSPACE to fetch TensorFlow 2.21.0
  • Problem: The build failed with numerous errors regarding missing or conflicting external repositories (e.g., rules_java, local_config_cuda, local_config_tensorrt, llvm-raw, etc.).
  • Reason: Upgrading to TensorFlow 2.21.0 introduced new transitive dependencies and assumed the presence of toolchains (like Java and GPU-specific configurations) not directly needed by struct2tensor.
  • Fix: We created multiple dummy repositories in the WORKSPACE file to satisfy these unresolved references without adding unnecessary overhead. We also applied custom patches to TensorFlow’s source files to remove Java, CUDA, ROCm, and TensorRT dependencies that were causing failures.

2. Python 3.12 Support and Python 3.9 Drop

  • Problem: The codebase needed to be updated to support Python 3.12 and drop support for the deprecated Python 3.9, aligning with newer TensorFlow requirements.
  • Reason: Evolving ecosystem standards and dependency compatibility demanded a Python version upgrade.
  • Fix: We modified setup.py and environment.yml to declare support for Python 3.12, dropped Python 3.9, and pinned compatible versions for critical libraries like pyarrow (>=14), h5py, and ml-dtypes.

3. Protobuf Version Mismatch (Compiler vs. Headers)

  • Problem: Build failed with fatal errors stating that generated Protobuf files (e.g., field_mask.pb.h) were generated by a newer version of protoc than the Protocol Buffer headers being included in compilation.
  • Reason: Bazel 7’s default Bzlmod behavior ignored the manual overrides specified in WORKSPACE, causing it to fetch mismatched Protobuf compilers and headers.
  • Fix: We explicitly disabled Bzlmod in .bazelrc using common --noenable_bzlmod and moved the register_toolchains call to the very top of the WORKSPACE file to enforce correct resolution priority. We also applied a specialized patch (protobuf_tensorflow.patch) to fix macro and namespace issues.

4. GCC 15 Linker Relocation Errors

  • Problem: The build failed during the linking stage with relocation errors related to SFrame sections.
  • Reason: Newer GCC versions (like GCC 15 on the local system) generate SFrame unwind information by default, which confused the linker in this specific Bazel setup.
  • Fix: Added the --copt=-Wa,--gsframe=no flag under the Linux configuration in .bazelrc to disable SFrame generation.

5. Test Sharding Validation Errors

  • Problem: Running benchmark tests threw errors stating that "Sharding was requested, but the test runner did not advertise support".
  • Reason: Bazel 7 enforces stricter checks on test sharding protocols by default.
  • Fix: Added test --noincompatible_check_sharding_support to .bazelrc to allow the tests to skip this check and execute successfully.

6. CI Pre-Commit Hook Failures

  • Problem: The newly introduced pre-commit workflow in GitHub Actions failed due to linting and small formatting issues.
  • Reason: Trailing whitespaces were left in patch files, and .bazelrc missed a proper newline at the end of the file.
  • Fix: We ran the hooks locally to automatically fix the formatting issues. We also identified that protobuf_retain_options.patch became redundant and deleted it to pass the clean check.

Verification

All tests passed successfully locally:

bazel test //... --noincompatible_check_sharding_support ...

@vkarampudi vkarampudi changed the title Testing1 Upgrade Struct2Tensor to TensorFlow 2.21.0 Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant